package com.woniuxy.exchangeType.direct;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.woniuxy.utils.Utils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class DirectProducer {
    public static void main(String[] args) throws IOException, TimeoutException {
        //获取连接
        Connection connection = Utils.getConnection();
        //对接通道
        Channel channel = connection.createChannel();
        //发布到对应的交换机和routinkey
        channel.basicPublish("directExchange","key1",null,"建立路由订阅模型01".getBytes());
        channel.basicPublish("directExchange","key2",null,"建立路由订阅模型02".getBytes());
        System.out.println("发送消息完成");
        //关闭资源
        channel.close();
        connection.close();
    }
}
